What is eslint-rule-documentation?
The eslint-rule-documentation npm package provides a way to get documentation URLs for ESLint rules. This can be useful for integrating with tools that display ESLint rule information or for generating documentation.
What are eslint-rule-documentation's main functionalities?
Get Documentation URL for a Rule
This feature allows you to get the documentation URL for a specific ESLint rule. The code sample demonstrates how to get the URL for the 'no-unused-vars' rule.
const ruleDocumentation = require('eslint-rule-documentation');
const result = ruleDocumentation('no-unused-vars');
console.log(result.url); // Outputs: 'https://eslint.org/docs/rules/no-unused-vars'
Get Documentation URL with Custom Rules
This feature allows you to provide custom rules with their documentation URLs. The code sample demonstrates how to get the URL for a custom rule 'my-custom-rule'.
const ruleDocumentation = require('eslint-rule-documentation');
const customRules = {
'my-custom-rule': 'https://example.com/docs/my-custom-rule'
};
const result = ruleDocumentation('my-custom-rule', customRules);
console.log(result.url); // Outputs: 'https://example.com/docs/my-custom-rule'
Other packages similar to eslint-rule-documentation
eslint-find-rules
eslint-find-rules is a package that helps you find and list all the rules available in your ESLint configuration, including custom rules. Unlike eslint-rule-documentation, it focuses on listing and managing rules rather than providing documentation URLs.
eslint-plugin-markdown
eslint-plugin-markdown allows you to lint JavaScript code blocks within Markdown files. While it doesn't provide documentation URLs for rules, it helps in ensuring that code snippets in documentation adhere to ESLint rules.
eslint-doc-generator
eslint-doc-generator is a tool for generating documentation for custom ESLint rules. It focuses on creating documentation files rather than providing URLs for existing rules, making it more suitable for developers who create their own ESLint rules.
eslint-rule-documentation
Find the url for the documentation of an ESLint rule
Install
$ npm install --save eslint-rule-documentation
Usage
const getRuleURI = require('eslint-rule-documentation');
getRuleURI('no-var');
getRuleURI('import/no-unresolved');
getRuleURI('unknown-foo/bar');
Contributing
If you find a plugin that you use is not in the list of supported plugins, please consider adding it to the project by following the instructions here.
API
getRuleURI(ruleId)
ruleId
Type: string
Id of an ESLint rule.
Examples:
returns
Type: object
{
found: <boolean>,
url: <string>
}
found
: true
if the rule is an ESLint core rule, or a rule of a known plugin, false
otherwise.url
: if found
is true
, url of the documentation of a rule. If found
is false
, url of the contribution guidelines.
Thanks
Special thanks to the team behind linter-eslint for the original work, and the people who contributed there.
License
MIT © Jeroen Engels